
class DoYunSuan():
    num = 100
    # 加
    def mySum(self, a, b):
        try:
            if isinstance(a,(int,float)) and isinstance(b,(int,float)):
                c = a + b
                if isinstance(a, (int, float)) and isinstance(b, (int, float)):
                    c=round(c,1)
        except Exception as e:
            print(f"处理mySum异常，异常信息是：{e}")
        else:
            print("未发生异常")
            return c
        finally:
            print("运算结束")
    def myJian(self, a, b):
        try:
            if isinstance(a, (int, float)) and isinstance(b, (int, float)):
                c = a - b
                if isinstance(a, (int, float)) and isinstance(b, (int, float)):
                    c = round(c, 1)
        except Exception as e:
            print(f"处理myJian异常，异常信息是：{e}")
        else:
            print("未发生异常")
            return c
        finally:
            print("运算结束")
    def myCheng(self, a, b):
        try:
            if isinstance(a, (int, float)) and isinstance(b, (int, float)):
                c = a * b
                if isinstance(a, (int, float)) and isinstance(b, (int, float)):
                    c = round(c, 1)
        except Exception as e:
            print(f"处理myCheng异常，异常信息是：{e}")
        else:
            print("未发生异常")
            return c
        finally:
            print("运算结束")
    def myChu(self, a, b):
        try:
            if isinstance(a, (int, float)) and isinstance(b, (int, float)):
                chu = a / b
                if isinstance(a, (float)) or isinstance(b, (float)):
                    chu = round(chu, 2)  # 四舍五入,保留两位小数
            else:
                return '您是非法输入'
        except Exception as e:
            print(f'处理加法时发生了异常,异常信息是{e}')
        else:
            print('没有异常')
            return chu
        finally:
            print('不确定是否发生了异常')

if __name__ == '__main__':
    ys=DoYunSuan()
    ys.mySum(20,90)
    ys.myJian(20,90)
    ys.myCheng(2,5)
    ys.myChu(6,0)